package net.zjitc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.zjitc.entity.Education;
import net.zjitc.mapper.EducationMapper;
import net.zjitc.service.IEducationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @auther 郭梦婷
 * @create 2022-04-27 16:13:09
 * @describe 服务实现类
 */
@Service
@Transactional
public class EducationServiceImpl extends ServiceImpl<EducationMapper, Education> implements IEducationService {

        @Autowired
        private EducationMapper educationMapper;
        @Override
        public Page<Education> getEducations(String querystring, Integer pagenum, Integer pagesize) {
                Page<Education> page=new Page<>(pagenum,pagesize);
                if (querystring.length()==0){
                        page = educationMapper.selectPage(page,null);
                }else {
                        QueryWrapper<Education> wrapper=new QueryWrapper<>();
                        wrapper.eq("eduname",querystring);
                        page = educationMapper.selectPage(page, wrapper);
                }
                return page;
        }

        @Override
        public int deleteById(int id) {
                int i = educationMapper.deleteById(id);
                return i;
        }

        @Override
        public List<Education> getAllEducations() {
                List<Education> educations = educationMapper.selectList(null);
                return educations;
        }
}
